import request from '@/utils/request'

// 获取知识库列表
export function getKnowledgeBaseList(params) {
  return request({
    url: '/knowledgebase',
    method: 'get',
    params
  })
}

// 获取知识库详情
export function getKnowledgeBaseDetail(id) {
  return request({
    url: `/knowledgebase/${id}`,
    method: 'get'
  })
}

// 创建知识库
export function createKnowledgeBase(data) {
  return request({
    url: '/knowledgebase',
    method: 'post',
    data
  })
}

// 更新知识库
export function updateKnowledgeBase(id, data) {
  return request({
    url: `/knowledgebase/${id}`,
    method: 'put',
    data
  })
}

// 删除知识库
export function deleteKnowledgeBase(id) {
  return request({
    url: `/knowledgebase/${id}`,
    method: 'delete'
  })
}

// 管理知识库文档
export function manageKnowledgeBaseDocuments(knowledgeBaseId, documentId, action = 'add') {
  const method = action === 'add' ? 'post' : 'delete'
  return request({
    url: `/knowledgebase/${knowledgeBaseId}/documents/${documentId}`,
    method
  })
}
//
export let document